package com.lidy.tankbattle.tankgame0;

import javax.swing.*;
import java.awt.*;

/**
 * @author lidy
 * @version V1.0
 * @classname MyPanel
 * @description 画板
 *  @date 2022/5/28 9:19
 */
public class MyPanel extends JPanel implements Runnable {
    int x = 10, y = 10;
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        if (x < 600 && y < 1000) {
            Toolkit toolkit = Toolkit.getDefaultToolkit();
            Image image = toolkit.getImage(MyPanel.class.getResource("/images/player1/tankD.gif"));
            g.drawImage(image, x, y,60,60, this);
        }
    }

    @Override
    public void run() {
        while (y < 500) {
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            this.repaint();
            y += 5;
        }
    }
}
